#!/usr/bin/python
# coding=utf-8

import plotly.plotly
import numpy
import PIL.Image
import urllib
import cStringIO

imagepath = "/Users/Vicky/Desktop/11.png"
# fff = cStringIO.cStringIO()
image_url = 'https://images.plot.ly/plotly-documentation/images/heatmap-galaxy.jpg'
f = cStringIO.StringIO(urllib.urlopen(image_url).read())
img = PIL.Image.open(f)
# img = PIL.Image.open(imagepath)
arr = numpy.array(img)
zdata = []
for i in range(500):
    k = []
    for j in range(500):
        k.append(sum(arr[i][j]))
    zdata.append(k)
trace = dict(
    type = "heatmapg1",
    z = zdata,
    colorscale="Picnic"
)
data = [trace]
layout = dict(
    width=700,
    height=700
)
fig = dict(
    data = data,
    layout= layout
)
print 51656
plotly.offline.plot(fig,filename="da.html")